package com.naiterui.ehp.bp.bo.doctor;

import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 内部接口 患者信息
 *
 * @author 王泽浩
 * @since 2.9.0
 */
@Getter
@Setter
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class RecomPatientBO implements java.io.Serializable {

    private static final long serialVersionUID = -1703589169193944833L;

    public static enum GenderEnum {

        GENDER_FEMALE(2, 0, "女"),
        GENDER_MALE(1, 1, "男"),
        GENDER_UNKNOWN(0, 2, "未知");

        private Integer weixinId;
        private Integer id;
        private String name;

        GenderEnum(Integer id, String name) {
            this.id = id;
            this.name = name;
        }

        GenderEnum(Integer weixinId, Integer id, String name) {
            this.weixinId = weixinId;
            this.id = id;
            this.name = name;
        }

        public Integer getWeixinId() {
            return weixinId;
        }

        public Integer getId() {
            return this.id;
        }

        public String getName() {
            return this.name;
        }

        public static GenderEnum val(Integer gender) {
            for (GenderEnum s : values()) {    // values()方法返回enum实例的数组
                if (gender == s.getId()) {
                    return s;
                }
            }
            return null;
        }

        public static GenderEnum getByWeixinId(Integer weixinId) {
            for (GenderEnum s : values()) {    // values()方法返回enum实例的数组
                if (weixinId == s.getWeixinId()) {
                    return s;
                }
            }
            return null;
        }
    }

    /**
     * 年龄单位
     *
     * @since 2.16
     */
    public enum AgeUnitEunm {
        WEEK("周"),
        MONTH("个月"),
        YEAR("岁");
        private String unit;

        private AgeUnitEunm(String unit) {
            this.unit = unit;
        }

        public String getUnit() {
            return unit;
        }

        public static AgeUnitEunm val(String unit) {
            if (StringUtils.isEmpty(unit)) {
                return null;
            }
            for (AgeUnitEunm s : values()) {    // values()方法返回enum实例的数组
                if (unit.equals(s.getUnit())) {
                    return s;
                }
            }
            return null;
        }
    }

    /**
     * 患者ID
     */
    private Long id;

    /**
     * 患者手机号
     */
    private String phone;

    /**
     * 患者unionId
     */
    private String unionId;

    /**
     * 患者姓名
     */
    private String name;

    /**
     * 患者年龄(单位岁；优先级：病例年龄>出生日期计算年龄>注册年龄)
     */
    private Integer age;

    /**
     * 患者性别：0.女 1.男
     */
    private Integer gender;

    /**
     * 患者头像
     */
    private String headUrl;
    /**
     * 精确年龄，单位精确到周(用于处方显示)
     */
    private Integer preciseAge;

    /**
     * 精确年龄单位
     */
    private String preciseAgeUnit;
    /**
     * 认证状态,0:未认证,1:已认证
     */
    private Integer status;
    /**
     * 身份证号
     */
    private String idCard;

    public String getGenderStr() {
        return this.getGenderStr(this.gender);
    }

    public String getGenderStr(Integer gender) {
        if (null == gender) {
            return GenderEnum.GENDER_UNKNOWN.getName();
        }
        String genderStr;
        GenderEnum genderEnum = GenderEnum.val(gender);
        switch (genderEnum) {
            case GENDER_FEMALE:
                genderStr = GenderEnum.GENDER_FEMALE.name;
                break;
            case GENDER_MALE:
                genderStr = GenderEnum.GENDER_MALE.name;
                break;
            case GENDER_UNKNOWN:
                genderStr = GenderEnum.GENDER_UNKNOWN.name;
                break;
            default:
                genderStr = GenderEnum.GENDER_UNKNOWN.name;
                break;
        }
        return genderStr;
    }


}
